Adding a second IP address onto eth0 causes the vif-* hotplug scripts to
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 22 Feb 2006 20:52:30 +0000 (21:52 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 22 Feb 2006 20:52:30 +0000 (21:52 +0100)
fail: ip_of() is returning a LIST of IP addresses, one per line.
The vif-scripts attempt to use the list where single addresses ought to
be, with predictable results. This patch changes ip_of() to return
the first address in the list, which seems to be the first one configured.

Signed-off-by: Jim Dykman <dykman@us.ibm.com>
tools/examples/vif-common.sh

index 3cbaa591b113bdee51352e5870ba6f35a913c367..6ce280c4f2af80ed8549d0191bec2ccd9a1afb6a 100644 (file)
@@ -125,7 +125,7 @@ function handle_iptable()
 #
 function ip_of()
 {
-  ip addr show "$1" | awk "/^.*inet.*$1\$/{print \$2}" | sed 's,/.*,,'
+  ip addr show "$1" | awk "/^.*inet.*$1\$/{print \$2}" | sed 's,/.*,,' | head -1
 }